window.onload = function() {
    //配置
    var config = {
            vx: 4, //点x轴速度,正为右，负为左
            vy: 4, //点y轴速度
            height: 2, //点高宽，其实为正方形，所以不宜太大
            width: 2,
            count: 100, //点个数
            color: "100, 100, 100", //点颜色
            stroke: "50,50,50", //线条颜色
            dist: 6000, //点吸附距离
            e_dist: 20000, //鼠标吸附加速距离
            max_conn: 10 //点到点最大连接数
        }
        //调用
    CanvasParticle(config, 'bannerCon');
}

// 右边内容 楼层滚动
function floorScroll() {
    //获取所有的楼层按钮
    let lis = document.querySelectorAll('.nav-item1');
    //获取所有的floor
    let floors = document.querySelectorAll('.floor');
    let timeId = null;
    lis.forEach(function(li, index) {
        li.addEventListener('click', function(e) {
            // console.log(li);
            let current = document.documentElement.scrollTop; //获取滚轮的距离
            let target = floors[index].offsetTop; //获取目标楼层距离
            console.log(current, target)
            if (target > current) { //判断目标距离与滚轮的的距离大小
                timeId = setInterval(function() {
                    current += 30; //每隔30毫秒current+30
                    document.documentElement.scrollTop = current; //将每30毫秒得到的结果返还给document.documentElement.scrollTop
                    if (Math.abs(target - current) < 30) {
                        clearInterval(timeId);
                        timeId = null;
                        document.documentElement.scrollTop = target
                    }
                }, 30)
            } else {
                timeId = setInterval(function() {
                    current -= 30
                    console.log(current);
                    // 设置滚动距离
                    document.documentElement.scrollTop = current
                        //判断目标距离和当前之间差距，有多少如果这个差距的绝对值，小于30px
                    if (Math.abs(target - current) < 30) {
                        //清除定时器
                        clearInterval(timeId)
                        timeId = null
                        document.documentElement.scrollTop = target
                    }
                }, 30)
            }
            lis.forEach(function(item, i) {
                item.classList.remove('currentitem')
            })
            li.classList.add('currentitem')
        })
    })
}
floorScroll()

let login = document.querySelector('.login')
generateLogin(mask)
login.addEventListener('click', function() {
    mask.style.display = 'block'
})

// 了解详情跳转
let details = document.querySelectorAll('.btm-link .link-text')
details.forEach(function(span, i) {
    span.addEventListener('click', function() {
        window.location.href = './customer-details.html'
    })
})